package com.neusoft.nep.supervise.controller;

import com.neusoft.nep.common.ViewSwitcher;
import javafx.fxml.FXML;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.Parent;
import javafx.fxml.FXMLLoader;
import java.io.IOException;
import java.net.URL;

public class MainViewController {
    @FXML
    private AnchorPane contentPane;
    @FXML
    private ImageView imageView;

    public void initialize() {
        Image image = new Image("image/welcome.png");
        imageView.setImage(image);
        imageView.fitWidthProperty().bind(contentPane.widthProperty());
        imageView.fitHeightProperty().bind(contentPane.heightProperty());
        imageView.setSmooth(true);
        imageView.setPreserveRatio(false);
    }

    public void loadView(String fxmlPath) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = ViewSwitcher.class.getResource(fxmlPath);
        fxmlLoader.setLocation(url);
        Parent root = fxmlLoader.load();
        contentPane.getChildren().setAll(root);
    }


    @FXML
    public void selectGrid() throws IOException {
        loadView("../supervise/view/SelectGridView.fxml");
    }

    @FXML
    public void feedbackList() throws IOException {
        loadView("../supervise/view/FeedbackListView.fxml");
    }
}